package o;

import android.content.Context;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.hianalytics.v2.HiAnalytics;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public abstract class dgh {
    private static List<dgf> ˏ = new CopyOnWriteArrayList();
    private static boolean ॱ = true;

    public static boolean ˎ() {
        return ॱ;
    }

    public static void ˎ(boolean z) {
        ॱ = z;
    }

    public static void ॱ(Context context, String str, String str2) {
        if (ʻ()) {
            ˋ();
            HiAnalytics.onEvent(context, str, str2);
        }
    }

    private static void ˋ() {
        String userId = UserSession.getInstance().getUserId();
        if (TextUtils.isEmpty(userId)) {
            userId = null;
        }
        HiAnalytics.setUPID(userId);
    }

    public static void ˎ(String str, LinkedHashMap<String, String> linkedHashMap) {
        if (ˎ()) {
            ˋ();
            HiAnalytics.onEvent(str, linkedHashMap);
            HiAnalytics.onReport();
        }
    }

    public static void onEvent(dge o_dge) {
        ॱ(o_dge.ˎ(), o_dge.ˏ(), o_dge.ˊ());
    }

    public static void ˏ() {
        if (ʻ()) {
            HiAnalytics.onReport();
        }
    }

    public static void ˏ(String str, LinkedHashMap<String, String> linkedHashMap) {
        if (ʻ()) {
            HiAnalytics.onResume(str, (LinkedHashMap) linkedHashMap);
        }
    }

    public static void ॱ(String str, LinkedHashMap<String, String> linkedHashMap) {
        if (ʻ()) {
            HiAnalytics.onPause(str, (LinkedHashMap) linkedHashMap);
        }
    }

    public static void ˋ(String str, LinkedHashMap<String, String> linkedHashMap) {
        if (ʻ()) {
            ˋ();
            if (HiAnalytics.getInitFlag()) {
                int size = ˏ.size();
                if (size > 0) {
                    for (int i = 0; i < size; i++) {
                        HiAnalytics.onEvent(((dgf) ˏ.get(i)).ˊ(), ((dgf) ˏ.get(i)).ˏ());
                    }
                    ˏ.clear();
                }
                HiAnalytics.onEvent(str, linkedHashMap);
                return;
            }
            ˏ.add(new dgf(str, linkedHashMap));
        }
    }

    public static long ॱ() {
        return System.currentTimeMillis();
    }

    public static void ˋ(Context context, String str, long j) {
        if (str != null && str.length() > 0) {
            ॱ(context, str, String.valueOf(System.currentTimeMillis() - j));
        }
    }

    public static void ˊ() {
        ˎ(true);
    }

    public static void ॱ(String str, String str2, String str3) {
        if (ʻ()) {
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            if (!TextUtils.isEmpty(str2)) {
                linkedHashMap.put(str2, str3);
            }
            ˋ();
            HiAnalytics.onEvent(0, str, linkedHashMap);
        }
    }

    private static boolean ʻ() {
        return ˎ() && diu.ˊ().ˋ();
    }
}
